import { _decorator } from "cc";
import { Entity } from "./Entity";
import { EventType } from "../enums/EventType";
import { eventDispatcher } from "../Constants";
const { ccclass } = _decorator;

@ccclass("IronSkeleton")
export class IronSkeleton extends Entity {

    protected registerEvents(): void {
        eventDispatcher.on(EventType.ATTACK_ENEMY, this.onAttack, this);
    }

    private onAttack(id: number): void {
        if (id === this.id) {
            this.state = Entity.State.DEATH;
            eventDispatcher.emit(EventType.ENEMY_DEATH, id);
        }
    }
}